<?php

/* @var $this \yii\web\View */
/* @var $content string */

use app\models\Mall;
use app\models\User;
use yii\helpers\Html;
use yii\helpers\Url;

$web = Url::base();
$url = Yii::$app->request->scriptUrl;
$integral_unit = \app\models\Mall::getCurrentInstitutionIntegralUnit();
$institution_code = Mall::getCurrentInstitutionCode();
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link href="<?= $web ?>/css/mall/global.css" rel="stylesheet" type="text/css">

    <link href="<?= $web ?>/css/mall/swiper.min.css" type="text/css" rel="stylesheet">
    <link href="<?= $web ?>/css/mall/animate.min.css" type="text/css" rel="stylesheet">

    <style>
        .footer .footxian {
            background: url(<?= $web ?>/images/mall/footxian.jpg);
        }

        .footer .footsx {
            background: url(<?= $web ?>/images/mall/footersx.jpg);
        }
    </style>
    <?php
    if (strtoupper($institution_code) == 'JG001400') {
        ?>
        <style>
            .head-search-btn {
                background-color: #169b65;
            }

            .head-search-btn:hover {
                background-color: #169b65;
            }

            .head-bottom {
                border-bottom: 2px solid #169b65;
            }

            .new-footer .foot-top-border {
                background: #169b65;
                border-top: 1px solid #169b65;
            }

            .head-navigation-selected .head-navigation-circular {
                border-color: #169b65;
            }

            .head-navigation-selected .head-navigation-words {
                color: #169b65;
            }

            .head-navigation-hover:hover .head-navigation-words {
                color: #169b65;
            }

            .head-navigation-hover:hover .head-navigation-circular {
                background-color: #169b65;
            }
        </style>
        <?php
    } ?>
    <!--jquery必须在swiper上面-->
    <script src="<?= $web ?>/js/jquery-1.10.2.min.js"></script>
    <![if !IE]>
    <script src="<?= $web ?>/js/mall/swiper-3.3.1.jquery.min.js"></script>
    <![endif]>
    <![if !IE]>
    <script src="<?= $web ?>/js/mall/swiper.animate1.0.2.min.js"></script>
    <![endif]>

    <script src="<?= $web ?>/js/mall/jquery.lazyload.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="<?= $web ?>/js/tools.js"></script>


    <script type="application/javascript">
        var mySessionStorage = window.sessionStorage;
        var myLocalStorage = window.localStorage;
        var myStorage = window.localStorage;
        var unitname = <?= json_encode(\app\models\Mall::getCurrentInstitutionIntegralUnit())?>;
        var unitSearchName = "按" + unitname + "搜索";
        $(document).ready(function () {
            var obj = $(".head-search-choice");
            var elem = $(".head-search-list");

            function search_choice() {
                $(".head-search-left").click(function () {
                    $(this).unbind();
                    obj.css({
                        "display": "block",
                        "height": "0"
                    });
                    obj.animate({
                        "height": "72px"
                    }, 300, function () {
                        search_choice();
                    })
                })
            }

            function search_out() {
                obj.mouseleave(function () {
                    $(".head-search-left").unbind();
                    elem.find(".head-search-words").unbind();
                    obj.unbind();
                    obj.animate({
                        "height": "0"
                    }, 300, function () {
                        obj.css({
                            "display": "none"
                        });
                        search_choice();
                        elem_btn();
                        search_out()
                    })
                });
            }

            function elem_btn() {
//                $("input.begin").focus();
                elem.find(".head-search-words").click(function () {
                    $(".head-search-left").unbind();
                    elem.find(".head-search-words").unbind();
                    obj.unbind();
                    if ($(this).html() == unitSearchName) {
                        $(".head-search-input").find(".keywords").css("display", "none");
                        $(".head-search-input").find(".input-integral").css("display", "block");
                        $("#filter_goods_name").val('');
                    } else if ($(this).html() == "按产品搜索") {
                        $(".head-search-input").find(".keywords").css("display", "block");
                        $(".head-search-input").find(".keywords").focus();
                        $(".head-search-input").find(".input-integral").css("display", "none");
                        $("#filter_integral_from").val('');
                        $("#filter_integral_to").val('');
                    }
                    $(".head-search-last").html($(this).html());
                    obj.animate({
                        "height": "0"
                    }, 300, function () {
                        obj.css({
                            "display": "none"
                        });
                        search_choice();
                        elem_btn();
                        search_out()
                    })
                })
            }

            search_choice();
            elem_btn();
        });

        function filter() {
            var filter_goods_name = $("#filter_goods_name").val();
            var filter_integral_from = $("#filter_integral_from").val();
            var filter_integral_to = $("#filter_integral_to").val();

            var href = "goods-list";
            if (filter_goods_name != null && filter_goods_name != '') {
                href = setUrlParam(href, 'goodsName', filter_goods_name);
                href = setUrlParam(href, 'goodsListTitle', encodeURIComponent("商品搜索：" + filter_goods_name));
            }
            if (filter_integral_from != null && filter_integral_from != '') {
                href = setUrlParam(href, 'integralFrom', filter_integral_from);
                href = setUrlParam(href, 'sort', 2);
                href = setUrlParam(href, 'goodsListTitle', encodeURIComponent(" 积分搜索"));
            }
            if (filter_integral_to != null && filter_integral_to != '') {
                href = setUrlParam(href, 'integralTo', filter_integral_to);
                href = setUrlParam(href, 'sort', 2);
                href = setUrlParam(href, 'goodsListTitle', encodeURIComponent(" 积分搜索"));
            }

            window.location.href = href;
        }
        $(function () {
            $("#filter_goods_name,#filter_integral_from,#filter_integral_to").keydown(function (e) {
                if (e.keyCode == 13) {
                    filter();
                }
            });
        });
    </script>

    <?= Html::csrfMetaTags() ?>
    <title><?= Html::encode($this->title) ?></title>
</head>
<body>
<script>
    $(function ($) {
        refreshCartGoodsCount();
    });
    function refreshCartGoodsCount() {
        requestJson('get-cart-goods-count', null, true, function (re) {
            if (re.status == 0) {
                if (re.data == '0') {
                    // $('.shop-car .shop-car-number').hide();
                } else {
                    //$('.shop-car .shop-car-number').show();
                    //$('.shop-car .shop-car-number').html(re.data);
                    $('.head-shopping-number').html(re.data);
                }

            }
        });
    }
</script>
<div class="head">
    <div class="head-top">
        <div class="head-top-content">
            <div class="head-phone head-content-list">
                <?php
                if (strtoupper($institution_code) == 'JG001424') { // 为链家专门添加一个400
                    ?>
                    客户服务：400-009-3199
                    <?php
                }else {
                    ?>
                    客户服务：400-860-3111
                    <?php
                }
                ?>
            </div>
            <a href="cart?institution_code=<?= $institution_code ?>">
                <div class="head-shopping head-content-list">
                    <div class="head-shopping-img"><img src="<?= $web ?>/images/mall/head-1.png"></div>
                    <div>购物袋</div>
                    <div class="head-shopping-number">0</div>
                </div>
            </a>
            <a href="order-list?institution_code=<?= $institution_code ?>">
                <div class="head-content-list head-order">
                    我的订单
                </div>
            </a>
            <div class="head-land head-content-list">
                <?php
                $currentUser = \app\models\Mall::getCurrentUser();
                if ($currentUser == null) {
                    ?>
                    <a href="login?return_url=<?= urlencode(Yii::$app->request->absoluteUrl) ?>" style="color: #e1515b;">登录</a>&nbsp;
                    <a href="" style="display:none;color: #333;">忘记密码?</a>
                    <?php
                } else {
                    ?>
                    <a href="user-information?institution_code=<?= $institution_code ?>" style="color: #e1515b;"><?= $currentUser['name'] ?></a>&nbsp;&nbsp;
                    <a href="logout?return_url=<?= urlencode(Yii::$app->request->absoluteUrl) ?>" style="color: #333;">退出</a>
                    <?php
                }
                ?>
            </div>
            <!---------机构切换-------------->
            <?php
            $instList = User::getInstitutionListByPhone($currentUser['phone']);
            if (count($instList) > 1) {

                $site_name = Mall::getCurrentInstitutionSiteName();
                ?>
                <div class="mechanisms">
                    <div class="cur-mechanism">
                        <img class="arrow-down-icon" src="<?= $web ?>/images/mall/arrow_down.png"/>
                        <p class="cur-name"><?= $site_name ?></p>
                    </div>
                    <div class="mechanisms-list" style="display: none;">
                        <ul>
                            <?php
                            foreach ($instList as $item) {
                                ?>
                                <li>
                                    <a href="redirect-inst-index?institution_code=<?= $item['institution_code'] ?>">
                                        <?= $item['site_name'] ?>
                                    </a>
                                </li>
                                <?php
                            }
                            ?>
                            <!--<li>
                                <a href="">鑫泰标准机构0</a>
                            </li>-->


                        </ul>
                    </div>
                    <script type="text/javascript">
                        $(function () {
                            $(".cur-name").click(function () {
                                $(".mechanisms-list").slideToggle();
                            });
                        });
                    </script>
                </div>
                <?php
            }
            ?>

            <!----------------------------------->
        </div>
    </div>
    <div class="head-bottom">
        <div class="head-bottom-content">
            <a href="index?institution_code=<?= $institution_code ?>"">
            <div class="head-bottom-logo">
                <?php
                if (strtoupper($institution_code) == 'JG001393') { // 为百胜专门添加一个logo
                    ?>
                    <img src="<?= $web ?>/images/mall/head-2-bs.png">
                    <?php
                } else if (strtoupper($institution_code) == 'JG001400') { // 为人寿专门添加一个logo
                    ?>
                    <img src="<?= $web ?>/images/mall/head-2-rs.png">
                    <?php
                } else if (strtoupper($institution_code) == 'JG001424') { // 为链家专门添加一个logo
                    ?>
                    <img src="<?= $web ?>/images/mall/lj.png">
                    <?php
                }
                else{
                    ?>
                    <img src="<?= $web ?>/images/mall/head-2.png">
                    <?php
                }
                ?>
            </div>
            </a>
            <div class="head-navigation">
                <a href="index?institution_code=<?= $institution_code ?>">
                    <?php
                    if ($this->context->navTag == 'index') {
                        echo '<div class="head-navigation-list head-navigation-selected">';
                    } else {
                        echo '<div class="head-navigation-list head-navigation-hover">';
                    }
                    ?>
                    <div class="head-navigation-circular">
                        <?php
                        if (strtoupper($institution_code) == 'JG001400') {
                            ?>
                            <img class="icon" src="<?= $web ?>/images/mall/head-navigation-1_1-rs.png">
                            <?php
                        } else {
                            ?>
                            <img class="icon" src="<?= $web ?>/images/mall/head-navigation-1_1.png">
                            <?php
                        }
                        ?>
                        <img class="head-navigation-img2" src="<?= $web ?>/images/mall/head-navigation-1_2.png">
                        <img class="head-navigation-img3" src="<?= $web ?>/images/mall/head-navigation-1_3.png">
                    </div>
                    <div class="head-navigation-words">首页</div>
            </div>
            </a>
            <a href="virtual-coupon-list?institution_code=<?= $institution_code ?>">
                <?php
                if ($this->context->navTag == 'virtual-coupon-list') {
                    echo '<div class="head-navigation-list head-navigation-selected">';
                } else {
                    echo '<div class="head-navigation-list head-navigation-hover">';
                }
                ?>
                <div class="head-navigation-circular">
                    <?php
                    if (strtoupper($institution_code) == 'JG001400') {
                        ?>
                        <img class="icon" src="<?= $web ?>/images/mall/head-navigation-2_1-rs.png">
                        <?php
                    } else {
                        ?>
                        <img class="icon" src="<?= $web ?>/images/mall/head-navigation-2_1.png">
                        <?php
                    }
                    ?>
                    <img class="head-navigation-img2" src="<?= $web ?>/images/mall/head-navigation-2_2.png">
                    <img class="head-navigation-img3" src="<?= $web ?>/images/mall/head-navigation-2_3.png">
                </div>
                <div class="head-navigation-words">免费福利</div>
        </div>
        </a>
        <!--<a href="javascript:void(0)">
            <div class="head-navigation-list head-navigation-hover">
                <div class="head-navigation-circular">
                    <img class="icon" src="<? /*= $web */ ?>/images/mall/head-navigation-3_1.png">
                    <img class="head-navigation-img2" src="<? /*= $web */ ?>/images/mall/head-navigation-3_2.png">
                    <img class="head-navigation-img3" src="<? /*= $web */ ?>/images/mall/head-navigation-3_3.png">
                </div>
                <div class="head-navigation-words">心仪产品</div>
            </div>
        </a>-->
        <a href="user-information?institution_code=<?= $institution_code ?>"><!--user-information   login-->
            <?php
            if ($this->context->navTag == 'user') {
                echo '<div class="head-navigation-list head-navigation-selected">';
            } else {
                echo '<div class="head-navigation-list head-navigation-hover">';
            }
            ?>
            <div class="head-navigation-circular">
                <?php
                if (strtoupper($institution_code) == 'JG001400') {
                    ?>
                    <img class="icon" src="<?= $web ?>/images/mall/head-navigation-4_1-rs.png">
                    <?php
                } else {
                    ?>
                    <img class="icon" src="<?= $web ?>/images/mall/head-navigation-4_1.png">
                    <?php
                }
                ?>
                <img class="head-navigation-img2" src="<?= $web ?>/images/mall/head-navigation-4_2.png">
                <img class="head-navigation-img3" src="<?= $web ?>/images/mall/head-navigation-4_3.png">
            </div>
            <div class="head-navigation-words">个人中心</div>
    </div>
    </a>
</div>
<div class="head-search">
    <div class="head-search-left">
        <div class="head-search-words head-search-last">按<?= $integral_unit ?>搜索</div>
        <div class="head-search-img">
            <img src="<?= $web ?>/images/mall/head-3.png">
        </div>
    </div>
    <div class="head-search-choice">
        <div class="head-search-left head-search-list">
            <div class="head-search-words">按<?= $integral_unit ?>搜索</div>
        </div>
        <br/>
        <div class="head-search-left head-search-list">
            <div class="head-search-words">按产品搜索</div>
        </div>
    </div>
    <div class="head-search-input">
        <input class="keywords" id="filter_goods_name" type="text" placeholder="请输入产品关键字">
        <div class="input-integral">
            <input class="begin" id="filter_integral_from" type="text" min="0" placeholder="开始<?= $integral_unit ?>数量"/><span>-</span><input type="text" min="0" id="filter_integral_to" class="end" placeholder="结束<?= $integral_unit ?>数量"/>
        </div>
    </div>
    <div class="head-search-btn" onclick="filter()">
        <img src="<?= $web ?>/images/mall/head-4.png">
    </div>
</div>
</div>
</div>
</div>

<?= $content ?>

<div class="clfl"></div>

<div class="new-footer">
    <div class="foot-top-border"></div>
    <div class="footer-content">
        <div class="wechat">
            <div class="accounts">
                <?php
                if (strtoupper($institution_code) == 'JG001424') { // 为链家修改二维码
                ?>
                <img src="<?= $web ?>/images/mall/lj_erweima.png"/>
                <?php
                  }else {
                    ?>
                    <img src="<?= $web ?>/images/mall/duolahe-weixin.jpg"/>
                    <?php
                }

                ?>
                <p>微信公众号</p>
                <p>扫码关注我们</p>
            </div>
            <div class="store">
                <?php $web_base = Url::base(true); ?>
                <img src="<?= Url::to(['mall-m/qr-code-out', 'text' => Url::to(['mall-m/index', 'institution_code' => $institution_code], true), 'margin' => 1, 'isCache' => true]) ?>"/>
                <p>手机商城</p>
                <p>兑换更方便</p>
            </div>
        </div>
         <?php
                if (strtoupper($institution_code) == 'JG001424') { // 为链家修改
                    ?>
                    <div class="corporate-information">
                        <p>全国服务热线：400-009-3199</p>
                        <p>联系电话：023-86502085</p>
                        <p>联系地址：重庆市九龙坡区马王乡龙泉路68号</p>
                        <p>重庆吉享汇电子商务有限公司版权所有Copyright © 2006-2013 吉享汇 渝ICP备16002556号-1</p>
                    </div>
                    <?php
                } else {
                    ?>
        <div class="corporate-information">
            <p>全国服务热线：400-860-3111</p>
            <p>联系电话：131 4839 4117</p>
            <p>联系地址：重庆市渝北区仙桃数据谷19号</p>
            <p>重庆鑫泰科技有限责任公司版权所有 Copyright©2016 All Rights Reserved | 渝ICP备15012802号</p>
        </div>
        <?php
        }
        ?>
    </div>
</div>
</body>
</html>
